import { Entity, PrimaryGeneratedColumn, Column, Index } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

/**
 * 挖宝坑位表（每个角色按页存储九宫格的9个坑位）
 * state: 0 未挖，1..8 奖励类型，中类类型码；9 空
 */
@Entity("tomb_pit")
@ManualTimestamp()
@Index(["characterId", "pageIndex"]) // 加速按页查询
export class TombPitEntity {
  @PrimaryGeneratedColumn({
    type: "int",
    comment: "坑位ID（作为前端 pitId 使用）",
  })
  id!: number;

  @Column({ type: "int", name: "character_id", comment: "角色ID" })
  characterId!: number;

  @Column({ type: "int", name: "page_index", comment: "页索引，从0开始" })
  pageIndex!: number;

  @Column({ type: "int", name: "pit_index", comment: "坑位索引，0..8" })
  pitIndex!: number;

  @Column({
    type: "int",
    name: "state",
    default: 0,
    comment: "坑位状态：0未挖，1..8奖励类型，9空",
  })
  state!: number;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date | null;
}
